package com.tester.yaa.exam002.multiThread;

import lombok.Data;

import java.util.Random;

/**
 * @Aduthor yinanan
 * @ClassName IntegerThread
 * @Date 2022/12/11 16:47
 * @Description 生成整数的线程
 **/
@Data
public class IntegerThread extends Thread {

    private static int number;

    /**
     * @Description: //产生随机数
     * @author: yinanan
     * @Param: []
     * @return: void
     * @Date: 2022/12/11
     */
    public void run() {
        //获取1-100的随机数
        Random random = new Random();
        number = random.nextInt(100);
        System.out.println("随机给你一个1-100之间的数字，猜猜是多少？");
        System.out.println("随机生成的数字为：" + number);
    }

    /**
     * @Description: //猜数字比较
     * @author: yinanan
     * @Param: [m]
     * @return: java.lang.String
     * @Date: 2022/12/11
     */
    public static String integerNumber(int m) {
        if (m < number) {
            return "你猜小了";
        } else if (m > number) {
            return "你猜大了";
        } else return "恭喜，你猜对了";
    }
}
